package com.ph.irp.base.verifyproject.action;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.ph.irp.base.assistantmaterial.service.AssistantmaterialIndustryService;
import com.ph.irp.base.assistantmaterial.service.PBaseAssistantmaterialAreaService;
import com.ph.irp.base.verifyproject.service.PBaseVerifyprojectCandiateService;
import com.ph.irp.base.verifyproject.service.PBaseVerifyprojectDepartmentService;
import com.ph.irp.base.verifyproject.service.PBaseVerifyprojectSupplierService;
import com.ph.irp.dto.CandiateDTO;
import com.ph.irp.dto.DepartmentDTO;
import com.ph.irp.dto.PageDTO;
import com.ph.irp.dto.SupplierDTO;
import com.ph.irp.model.PBaseAssistantmaterialArea;
import com.ph.irp.model.PBaseAssistantmaterialIndustry;
import com.ph.irp.model.PBaseVerifyprojectSupplier;
import com.ph.util.pagination.PageUtil;
import com.ph.util.pagination.ShowPageList;

public class VerifyprogectSupplierAction extends ActionSupport implements ShowPageList {
	private String FORWARD = null;

	private PBaseVerifyprojectSupplierService supplierService;
	private SupplierDTO supplierDTO;
	private List<SupplierDTO> supplierList;
	private List<SupplierDTO> tempSupplierList;
	private PBaseVerifyprojectSupplier supplierModel;
	private String[] rowlist;
	private PBaseAssistantmaterialAreaService areaService;
	private AssistantmaterialIndustryService assistantmaterialIndustryService;
	private PBaseVerifyprojectDepartmentService departmentService;
	private PBaseVerifyprojectCandiateService candiateService;
	private PBaseAssistantmaterialArea areaModel;
	private PBaseAssistantmaterialIndustry industryModel;
	private DepartmentDTO deptDto;
	private CandiateDTO canDto;
	private PageDTO page;
	private String cpage;
	
	public PageDTO getPage() {
		return page;
	}

	public void setPage(PageDTO page) {
		this.page = page;
	}

	public String getCpage() {
		return cpage;
	}

	public void setCpage(String cpage) {
		this.cpage = cpage;
	}

	public PBaseVerifyprojectDepartmentService getDepartmentService() {
		return departmentService;
	}

	public void setDepartmentService(
			PBaseVerifyprojectDepartmentService departmentService) {
		this.departmentService = departmentService;
	}

	public PBaseVerifyprojectCandiateService getCandiateService() {
		return candiateService;
	}

	public void setCandiateService(
			PBaseVerifyprojectCandiateService candiateService) {
		this.candiateService = candiateService;
	}

	public DepartmentDTO getDeptDto() {
		return deptDto;
	}

	public void setDeptDto(DepartmentDTO deptDto) {
		this.deptDto = deptDto;
	}

	public CandiateDTO getCanDto() {
		return canDto;
	}

	public void setCanDto(CandiateDTO canDto) {
		this.canDto = canDto;
	}

	public PBaseAssistantmaterialArea getAreaModel() {
		return areaModel;
	}

	public void setAreaModel(PBaseAssistantmaterialArea areaModel) {
		this.areaModel = areaModel;
	}

	public PBaseAssistantmaterialIndustry getIndustryModel() {
		return industryModel;
	}

	public void setIndustryModel(PBaseAssistantmaterialIndustry industryModel) {
		this.industryModel = industryModel;
	}

	public PBaseAssistantmaterialAreaService getAreaService() {
		return areaService;
	}

	public void setAreaService(PBaseAssistantmaterialAreaService areaService) {
		this.areaService = areaService;
	}

	public AssistantmaterialIndustryService getAssistantmaterialIndustryService() {
		return assistantmaterialIndustryService;
	}

	public void setAssistantmaterialIndustryService(
			AssistantmaterialIndustryService assistantmaterialIndustryService) {
		this.assistantmaterialIndustryService = assistantmaterialIndustryService;
	}

	public List<SupplierDTO> getSupplierList() {
		return supplierList;
	}

	public void setSupplierList(List<SupplierDTO> supplierList) {
		this.supplierList = supplierList;
	}

	public PBaseVerifyprojectSupplier getSupplierModel() {
		return supplierModel;
	}

	public void setSupplierModel(PBaseVerifyprojectSupplier supplierModel) {
		this.supplierModel = supplierModel;
	}

	public String[] getRowlist() {
		return rowlist;
	}

	public void setRowlist(String[] rowlist) {
		this.rowlist = rowlist;
	}

	public PBaseVerifyprojectSupplierService getSupplierService() {
		return supplierService;
	}

	public void setSupplierService(
			PBaseVerifyprojectSupplierService supplierService) {
		this.supplierService = supplierService;
	}

	public SupplierDTO getSupplierDTO() {
		return supplierDTO;
	}

	public void setSupplierDTO(SupplierDTO supplierDTO) {
		this.supplierDTO = supplierDTO;
	}

	public String addSupplier() throws Throwable {
		supplierService.addSupplier(supplierModel);
		FORWARD = "success";
		return FORWARD;
	}

	public String deleteSupplier() throws Throwable {
		supplierService.deleteSupplier(rowlist);
		FORWARD = "success";
		return FORWARD;
	}

	public String showEditSupplier() throws Throwable {
		supplierModel = supplierService.getSupplierById(Integer
				.valueOf((String) rowlist[0]));
		return "success";
	}

	public String showSupplierList() throws Throwable {
		tempSupplierList = supplierService.getAllSupplier();
		
		page = PageUtil.generatePageDTO(tempSupplierList, "showSupplierPageList.action", cpage);
		supplierList = page.getResList();
		
		FORWARD = "success";
		return FORWARD;

	}

	public String getSupplierByCondition() throws Throwable {
		tempSupplierList = supplierService.getSupplierByCondition(supplierModel);
		page = PageUtil.generatePageDTO(tempSupplierList, "showSupplierPageList.action", cpage);
		supplierList = page.getResList();
		supplierModel=null;
		FORWARD = "success";
		return FORWARD;
	}

	public String showPageList() throws Throwable {
		if (tempSupplierList != null) {
			page = PageUtil.generatePageDTO(tempSupplierList,
					"showSupplierPageList.action", cpage);
			supplierList = page.getResList();
			FORWARD = "success";
		} else {
			FORWARD = "input";
		}
		return FORWARD;
	}
	
	public String supplierSelect() throws Throwable {
		tempSupplierList = supplierService.getAllSupplier();
		page = PageUtil.generatePageDTO(tempSupplierList, "showSupplierPageList.action", cpage);
		supplierList = page.getResList();
		FORWARD = "success";
		return FORWARD;
	}
	

	public String editSupplier() throws Throwable {
		supplierService.updateSupplier(supplierModel);

		FORWARD = "success";
		return FORWARD;
	}

}
